function getRadtagSearchUrl(freeSearchOp, matchingAllTerms, matchingSearchHash) {
    return "/addama-rest/dudley-sample/path/datasource/Multiplex/search?" + freeSearchOp + matchingAllTerms +
           "&PROJECTION=chemicalName" +
           "&PROJECTION=location" +
           "&PROJECTION=reorderKey" +
           "&PROJECTION=alias" +
           "&PROJECTION=keyword" +
           "&PROJECTION=comments" +
           matchingSearchHash;
}

function getRadtagPagingColumns() {
    return [
        {
            name: 'indexNum',
            type: 'float'
        },
        {
            name: 'key'
        },
        {
            name: 'chemicalName'
        },
        {
            name: 'location'
        },
        {
            name: 'reorderKey'
        },
        {
            name: 'alias'
        },
        {
            name: 'keyword'
        },
        {
            name: 'comments'
        }
    ];

}

function translateRadtagResultToJson(jsonSearchArray) {
    var jsonObj = [];
    var chemKey = jsonSearchArray.name;
    jsonObj[0] = chemKey.substring(4, chemKey.length);
    jsonObj[1] = jsonSearchArray.name;
    jsonObj[2] = jsonSearchArray.chemicalName;
    jsonObj[3] = jsonSearchArray.location;
    jsonObj[4] = jsonSearchArray.reorderKey;
    jsonObj[5] = jsonSearchArray.alias;
    jsonObj[6] = jsonSearchArray.keyword;
    jsonObj[7] = jsonSearchArray.comments;

    /*var obsolete = jsonSearchArray.deletedRadtag;
    if (obsolete != undefined) {
        jsonObj[0] = jsonSearchArray.name;
        jsonObj[1] = jsonSearchArray.chemicalName;
        jsonObj[2] = "Record Deleted, contact Cathy/Jake to recover " + jsonSearchArray.name;
        jsonObj[3] = "Record Deleted";
    }*/
    return jsonObj;
}

function initRadtagJson(oligoHash) {
    oligoHash.chemicalName = undefined;
    oligoHash.location = undefined;
    oligoHash.reorderKey = undefined;

}

function getRadtagSearchOptionsArray() {
    return [
        ['all', 'All'],
        ['chemicalKey', 'chemicalKey'],
        ['chemicalName', 'chemicalName'],
        ['location', 'location'],
        ['reorderKey', 'reorderKey']
    ];
}

function getRadtagSearchColumnHeaders() {
    return  [
        {
            header: 'Index',
            width: 50,
            sortable: true,
            dataIndex: 'indexNum'
        },
        {
            id:'chemicalKey',
            header: 'RadtagKey',
            minColumnWidth: 100,
            sortable: true,
            dataIndex: 'key'
        },
        {
            header: 'Name',
            width: 200,
            sortable: true,
            dataIndex: 'chemicalName'
        },
        {
            header: 'Location',
            width: 100,
            sortable: true,
            dataIndex: 'location'
        },
        {
            header: 'Re-Order Key',
            width: 250,
            sortable: true,
            dataIndex: 'reorderKey'
        },
        {
            header: 'Keyword',
            width: 100,
            sortable: true,
            dataIndex: 'keyword'
        }

    ];
}

function populateRadtagJson(oHash, g) {
    oHash.name = g.getSelectionModel().getSelected().data.key;
    oHash.chemicalName = g.getSelectionModel().getSelected().data.chemicalName;
    oHash.location = g.getSelectionModel().getSelected().data.location;
    oHash.reorderKey = g.getSelectionModel().getSelected().data.reorderKey;
    oHash.alias = g.getSelectionModel().getSelected().data.alias;
    oHash.keyword = g.getSelectionModel().getSelected().data.keyword;
    oHash.comments = g.getSelectionModel().getSelected().data.comments;
}

function validateCreateUpdateRadtag() {
    /*
     if (Ext.getCmp("chemicalNameId").getValue() == null || Ext.getCmp("chemicalNameId").getValue() == "") {
     Ext.Msg.alert('Error', 'Radtag name is required.');
     return false;
     } else if (Ext.getCmp("chemicalLocationId").getValue() == null || Ext.getCmp("chemicalLocationId").getValue() == "") {
     Ext.Msg.alert('Error', 'Location is required.');
     return false;
     }
     */
    return true;
}




